import {applyMiddleware, createStore} from 'redux'
import thunk from 'redux-thunk'
import appReducer from '../reducer'
import {middleware} from "../navigator";
import {composeWithDevTools} from 'remote-redux-devtools'
const logger = store=>next=>action=>{
    if ( typeof action === 'function'){
        console.log('dispatch a function')
    }else{
        console.log('dispatch:',action)
    }
    const result = next(action)
    console.log('nextState:',store.getState())
}

const middlewares = [
    middleware,
    logger,
    thunk
]
const composeEnhancers = composeWithDevTools({ realtime: true, port: 8081 }); //未生效
/**
 * 创建store
 */
export default createStore(appReducer, composeEnhancers(applyMiddleware(...middlewares)))